package com.shi.util;

import java.awt.Graphics;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

public// 图
class TuPanel extends JPanel {

	public URL tu;

	public TuPanel() {

	}

	public void paintComponent(Graphics g) {
		int x = 0, y = 0;
	

		
		ImageIcon icon = new ImageIcon(tu);
		g.drawImage(icon.getImage(), x, y, getSize().width, getSize().height, this);
		while (true) {
			g.drawImage(icon.getImage(), x, y, this);
			if (x > getSize().width && y > getSize().height)
				break;
			// 这段代码是为了保证在窗口大于图片时，图片仍能覆盖整个窗口
			if (x > getSize().width) {
				x = 0;
				y += icon.getIconHeight();
			} else
				x += icon.getIconWidth();
		}
	}
}